#include "server.hpp"

int main() {
    Socket sock;
    sock.create_client("127.0.0.1", 8080);
    for(int i = 0; i < 3; ++i) {
        cout << "----------------------------------------------------------------" << endl;
        string msg = "Hello from client " + to_string(i) + "\n";
        ssize_t n = sock.send(msg.c_str(), msg.size());
        if(n <= 0) {
            continue;
        }
        printf("server send a %ld byts msg\n", n);
        char buffer[1024] = {0};
        n = sock.recv(buffer, sizeof(buffer) - 1);
        if(n <= 0) {
            continue;
        }
        cout << buffer << endl;
        sleep(1);
    }
    while(1) {
        sleep(1);
    }
    return 0;
}